Create Database SQL2008TVP
Go

Use SQL2008TVP
Go


CREATE TABLE dbo.Employee(
EmpID int NOT NULL,
EmpName nvarchar(100) NOT NULL,
EmpEmail nvarchar(100) NOT NULL)
Go

select * from dbo.Employee

delete from dbo.Employee

CREATE PROCEDURE NewEmployeeWithMultiParams(@EmpID int,@EmpName
nvarchar(100),@EmpEmail nvarchar(100))
As
BEGIN
INSERT INTO dbo.Employee
values(
@EmpID, @EmpName, @EmpEmail)
END


execute NewEmployeeWithMultiParams 1,'Brad Pitt','BradPitt@oceans11.com'

execute NewEmployeeWithMultiParams 2,'Matt Damon','MattDamon@oceans11.com'

execute NewEmployeeWithMultiParams 3,'George Clooney','GeorgeClooney@Oceans11.com'


CREATE TYPE EmployeeTableType AS TABLE
(EmpID INT, EmpName nvarchar(100), EmpEmail nvarchar(100))

CREATE PROCEDURE NewEmployee(@EmployeeDetails
EmployeeTableType READONLY)
As
BEGIN
INSERT INTO dbo.Employee
SELECT * FROM @EmployeeDetails
END



DECLARE @Employees EmployeeTableType

INSERT INTO @Employees
VALUES(1,'Brad Pitt','BradPitt@Oceans12.com')

INSERT INTO @Employees
VALUES(2,'Matt Damon','MattDamon@Oceans12.com')

INSERT INTO @Employees
VALUES(3,'George Clooney','GeorgeClooney@Oceans12.com')


EXECUTE NewEmployee @Employees

select * from @Employees

